<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>#ErrorStdOut</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#ErrorStdOut</h1>

<p>Sends any syntax error that prevents a script from launching to <strong>stderr</strong> rather than displaying a dialog.</p>

<pre class="Syntax">#ErrorStdOut</pre>
<p><span class="ver">[AHK_L 42+]:</span> Errors are written to stderr instead of stdout. The command prompt and fancy editors usually display both. This change was undocumented until after v1.1.19.01.</p>
<p>This allows fancy editors such as Textpad, SciTE, Crimson, and EditPlus to jump to the offending line when a syntax error occurs. Since the #ErrorStdOut directive would have to be added to every script, it is usually better to set up your editor to use the <a href="../Scripts.htm#cmd">command line switch</a> <strong>/ErrorStdOut</strong> when launching any AutoHotkey script (see further below for setup instructions).</p>
<p>Because AutoHotkey is not a console program, errors will not appear at the command prompt directly. Instead, such output can be captured via piping or redirection. For example:</p>
<pre>&quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&quot; /ErrorStdOut &quot;My Script.ahk&quot; <strong>2&gt;&amp;1 |more</strong>
&quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&quot; /ErrorStdOut &quot;My Script.ahk&quot; <strong>2&gt;&quot;Syntax-Error Log.txt&quot;</strong></pre>
<p>You can also pipe the output directly to the clipboard by downloading <a href="http://www.autohotkey.com/misc/cb.zip">cb.zip</a> (4 KB) and then following this example:</p>
<pre>&quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&quot; /ErrorStdOut &quot;My Script.ahk&quot; <strong>2&gt;&amp;1 |cb.exe</strong></pre>
<p><strong>Note:</strong> <code>2&gt;&amp;1</code> causes stderr to be redirected to stdout, while <code>2&gt;<i>Filename</i></code> redirects only stderr to a file.</p>

<h3>Instructions for specific editors</h3>
<p><strong>EditPlus</strong>:<br>
From the menu bar, select Tools &gt; Configure User Tools.<br>
Press button: Add Tool &gt; Program<br>
Menu Text: Your choice<br>
Command: C:\Program Files\AutoHotkey\AutoHotkey.exe<br>
Argument: /ErrorStdOut &quot;$(FilePath)&quot;<br>
Initial directory: $(FileDir)<br>
Capture output: Yes</p>
<p><strong>TextPad</strong>:<br>
  From the menu bar, select Configure &gt; Preferences.<br>
  Expand the Tools entry.<br>
Press the Add button and select &quot;Program&quot;.<br>
  Copy and paste (adjust to your path): <em>C:\Windows\System32\cmd.exe</em> -- then press OK.<br>
  Triple-click the newly added item (cmd.exe) in the ListBox and rename it to your choice (e.g. Launch Script).<br>
  Press Apply. <br>
  Select the new item in the tree at the left and enter the following information:<br>
  Command (should already be filled in): cmd.exe (or the full path to it)<br>
  Parameters (adjust to your path, if necessary): /c &quot;&quot;C:\Program Files\AutoHotkey\AutoHotkey.exe&quot; /ErrorStdOut &quot;$File&quot;&quot;<br>
  Initial folder: $FileDir<br>
  Check the following boxes:
  1) Run minimized; 2) Capture output.<br>
  Press OK. The newly added item should now exist in the Tools menu.</p>
<h3>Related</h3>
<p><a href="FileAppend.htm">FileAppend</a> (because it can also send text to stdout)</p>
<h3>Example</h3>
<pre class="NoIndent">#ErrorStdOut</pre>

</body>
</html>
